/**
 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
 * agreements.  See the NOTICE file distributed with this work for additional information regarding
 * copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with the License.  You may obtain
 * a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package org.apache.zookeeper.server.quorum.flexible;

import java.util.HashSet;

/**
 * 法定人数核检员
 * {@link QuorumVerifier#containsQuorum} 方法验证server id集合是否构成一个可用集群（法定人数）
 *
 * verifier n.	核对员，检验员；核对器，检验器
 */
public interface QuorumVerifier {

    long getWeight(long id);

    /**
     * 判断给定的sid set，判断能否组成法定人数
     *
     * 通俗讲，就是判断集群中server数量是否大于二分之一，如果大于二分之一就表示为达到了法定人数(quorum)
     * Verifies if a given set is a quorum.
     *
     * @param set sid set
     */
    boolean containsQuorum(HashSet<Long> set);
}
